package org.wattdepot.cli.commands;

/**
 * A summary of all the available commands and its format.
 * 
 * @author Paul Galiza
 * @author David Joel Lazaro
 * 
 */
public class HelpCommand {

  // For testing the buffer appends
  private int testBufferAppend = 0;

  /**
   * Lists all the commands, its format and a short summary of what each command does.
   * 
   * @return Returns the string commands and summary.
   */
  protected String help() {
    StringBuffer buff = new StringBuffer(2000);

    // Command 2.1
    buff.append("help\n");
    testBufferAppend++;
    buff.append("  Displays the help menu.\n");
    testBufferAppend++;
    // Command 2.2
    buff.append("quit\n");
    testBufferAppend++;
    buff.append("  Exits the system.\n");
    testBufferAppend++;
    // Command 2.3
    buff.append("sources\n");
    testBufferAppend++;
    buff.append("  Prints a table summarizing the public sources in the system, one per line.\n");
    testBufferAppend++;
    // Command 2.4
    buff.append("summary {source}\n");
    testBufferAppend++;
    buff.append("  Prints information about a single source.\n");
    testBufferAppend++;
    // Command 2.5
    buff.append("sensordata {source} timestamp {timestamp}\n");
    testBufferAppend++;
    buff.append("  Prints information about a single sensor data instance.\n");
    testBufferAppend++;
    // Command 2.6
    buff.append("dailysensordata {source} day {day}\n");
    testBufferAppend++;
    buff.append("  Prints a table listing all of the sensor data instances for "
        + "the specified day.\n");
    testBufferAppend++;
    // Command 2.7
    buff.append("power [generated|consumed] {source} timestamp {timestamp}\n");
    testBufferAppend++;
    buff.append("  Prints the power generated (or consumed) by the source at the "
        + "given timestamp. The power value is interpolated if there is no corresponding "
        + "sensor data instance.\n");
    testBufferAppend++;
    // Command 2.8
    buff.append("powerstats [generated|consumed] {source} day {day} sampling-interval"
        + " {minutes} statistic {max|min|average}\n");
    testBufferAppend++;
    buff.append("  Returns the maximum, minimum, or average power generated (or consumed) "
        + "by the source for the day. The statistic is obtained by sampling"
        + "the specified minute intervals for the course of the day.\n");
    testBufferAppend++;
    // Command 2.9
    buff.append("total [carbon|energy] generated {source} day {day} sampling-interval"
        + " {minutes}\n");
    testBufferAppend++;
    buff.append("  Returns the total amount of carbon (or energy) generated (or consumed) "
        + "by this source for the given day. The sampling interval indicates how to generate "
        + "the curve of carbon (or energy) data points.\n");
    testBufferAppend++;
    // Command 2.10
    buff.append("chart power [generated|consumed] {source} {startday} {endday} sampling-"
        + "interval {minutes} file {file}\n");
    testBufferAppend++;
    buff.append("  Writes out an html file that when displayed in a browser will show "
        + "a chart representation of the power generated (or consumed) by this source from "
        + "startday to endday, where data points are generated at a sampling interval of "
        + "minutes.\n");
    testBufferAppend++;
    buff.append("fueltypes {source}\n");
    testBufferAppend++;
    buff.append("  Returns a table of fuels associated with this source.\n");
    testBufferAppend++;
    buff.append("totalpower {source} {timestamp} fuelType {fuelType}\n");
    testBufferAppend++;
    buff.append("  Returns the total power generated by the given fuel type.\n");
    testBufferAppend++;
    buff.append("carboncontent {source} {timestamp} sampling-interval {interval}\n");
    testBufferAppend++;
    buff.append("  Returns the total carbon that would be emitted by that source over an hour "
        + "at the rate occurring as of the timestamp.");
    testBufferAppend++;

    return buff.toString();
  }

  /**
   * For testing purposes, returns the buffer length.
   * 
   * @return Returns the buffer length.
   */
  public int getTestBufferAppend() {
    return this.testBufferAppend;
  }
}
